using System;
using System.Collections.Generic;
using System.Linq;
using AutoPoco.Engine;

namespace Autopoco.Contrib.DataSources
{
    public class EnumDataSource<T> : DatasourceBase<T>
    {
        private readonly Random _random = new Random(100);
        private readonly IList<T> _list;

        public EnumDataSource()
        {
            _list = Enum.GetValues(typeof(T)).OfType<T>().ToList();

        }
        public override T Next(IGenerationSession session)
        {
            return _list[_random.Next(0, _list.Count - 1)];
        }
    }
}